/**
 * Copyright (c) 2021 zhaodongyang
   CurtainJs is licensed under Mulan PSL v2.
   You can use this software according to the terms and conditions of the Mulan PSL v2.
   You may obtain a copy of Mulan PSL v2 at:
            http://license.coscl.org.cn/MulanPSL2
   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
   See the Mulan PSL v2 for more details.
 */

import {config} from '../../../common/js/config.js'

export default {
    data: {
        title: 'World',
        canvasColor: "#333333",
        configList: [new config(0, 0, 0, 0, ""), new config(0, 0, 0, 0, "")],
        autoWidth: -100,
        drawerShow: true
    },
    props: {
        initShow: true
    },
    computed: {
        isDrawerShow() {
            return this.drawerShow
        }
    },
    onReady() {
        this.drawerShow = this.initShow
    },
    initHighLightData(rootView) {
        const context = this;
        try {
            if (rootView == null) {
                return
            }
            context.data.configList.splice(0)
            context.addImageToList(rootView)
            context.addRoundButtonToList(rootView)
            context.addDiyToList(rootView)
        } catch (err) {
            console.log("测试打印===err 2===" + err)
        }
    },
    addImageToList(rootView) {
        let ivBackground = rootView.$element('ivBackground')
        let tempLeft = ivBackground.getBoundingClientRect().left
        let tempTop = ivBackground.getBoundingClientRect().top
        let tempWidth = ivBackground.getBoundingClientRect().width
        let tempHeight = ivBackground.getBoundingClientRect().height
        let cssMarginTop = 10 // 无法动态获取css里面的MarginTop 本地写死
        let cssMarginLeft = 20 // 无法动态获取css里面的MarginTop 本地写死
        let cssMarginRight = 20 // 无法动态获取css里面的MarginTop 本地写死
        let bean = {
            left: tempLeft + cssMarginLeft,
            top: tempTop + cssMarginTop,
            width: tempWidth - cssMarginLeft - cssMarginRight,
            height: tempHeight - cssMarginTop,
            id: 'ivBackground',
            isDraw: true
        }
        this.data.configList.push(bean)
    },
    addRoundButtonToList(rootView) {
        let btCircle = rootView.$element('btCircle')
        let tempLeft = btCircle.getBoundingClientRect().left
        let tempTop = btCircle.getBoundingClientRect().top
        let tempWidth = btCircle.getBoundingClientRect().width
        let tempHeight = btCircle.getBoundingClientRect().height
        let cssMarginTop = 10 // 无法动态获取css里面的MarginTop 本地写死
        let cssMarginLeft = 20 // 无法动态获取css里面的MarginTop 本地写死
        let bean = {
            left: tempLeft + cssMarginLeft,
            top: tempTop + cssMarginTop,
            width: tempWidth - cssMarginLeft,
            height: tempHeight - cssMarginTop,
            id: 'btCircle',
            isDraw: true
        }
        this.data.configList.push(bean)
    },
    addDiyToList(rootView) {
        let tvDiy = rootView.$element('tvDiy')
        let tempLeft = tvDiy.getBoundingClientRect().left
        let tempTop = tvDiy.getBoundingClientRect().top
        let tempHeight = tvDiy.getBoundingClientRect().height
        let tempWidth = tvDiy.getBoundingClientRect().width
        let cssMarginLeft = 20 // 无法动态获取css里面的MarginLeft 本地写死
        let cssMarginTop = 20 // 无法动态获取css里面的MarginTop 本地写死
        // 左 上各减去5
        let bean = {
            left: tempLeft + cssMarginLeft - 5,
            top: tempTop + cssMarginTop - 5,
            width: tempWidth + 10 - cssMarginLeft,
            height: tempHeight + 10 - cssMarginTop,
            id: 'tvDiy',
            isDraw: true
        }
        this.data.configList.push(bean)
    },
    childClick(e) {
        this.$emit('eventType1', {
            type: "testClick",
            canShow: true
        });
    },
}
